<template>
	<view>
		<view class="form_active_title">“告诉我，你目前的求职状态是什么？”</view>
		<u-field disabled required :value="currentName" label="当前求职状态" placeholder="点击选择求职状态"
			@click="showPickerCurrent = true" class="form_choose reset_after big_label" />
		<u-picker v-model="showPickerCurrent" :range="columnsCurrent" range-key="text" mode="selector"
			@confirm="onConfirmCurrent" @cancel="showPickerCurrent = false" />
		<u-field placeholder-style="color:#757575;font-size:14px !important;" disabled required
			:value="enter_job_time_name" label="开始工作时间" placeholder="请选择"
			@click="showPickerEnterJob = !showPickerEnterJob" class="form_choose reset_after big_label" />
		<!-- <view class="for-pop-title" @click="handleNoJobTime">无工作经验</view> -->
		<u-picker :params="dateParams" v-model="showPickerEnterJob" :start-year="minDate" :end-year="maxDate"
			mode="time" title="无工作经验" @confirm="onConfirmEnterJob" @cancel="showPickerEnterJob = false" />
		<view style="margin: 32rpx;">
			<u-button shape="circle" type="primary" @click="handleSubmit">
				下一步
			</u-button>
		</view>
		<u-top-tips ref="uTips"></u-top-tips>
	</view>
</template>

<script>
	import http from '@/utils/http'
	import api from '@/api'
	export default {
		name: 'RegIntStep3',
		created() {
			this.$store.dispatch('getClassify', 'current')
			this.initDate()
		},
		computed: {
			columnsCurrent() {
				return this.$store.state.classifyCurrent
			}
		},
		data() {
			return {
				dateParams: {
					year: true,
					month: true,
					day: false,
					hour: false,
					minute: false,
					second: false,
					// 选择时间的时间戳
					timestamp: true,
				},
				minDate: '',
				maxDate: '',
				enter_job_time: '',
				enter_job_time_name: '',
				current: 0,
				currentName: '',
				showPickerCurrent: false,
				showPickerEnterJob: false
			}
		},
		methods: {
			// 设置日期插件默认值
			initDate() {
				let nowDate = new Date()
				let nowYear = nowDate.getFullYear()
				this.minDate = nowYear - 59
				this.maxDate = nowYear
			},
			handleNoJobTime() {
				this.enter_job_time = ''
				this.enter_job_time_name = '无工作经验'
				this.showPickerEnterJob = !this.showPickerEnterJob
			},
			//开始工作时间
			onConfirmEnterJob(value) {
				let {
					month,
					year
				} = value
				this.enter_job_time = year + '-' + month
				this.enter_job_time_name = year + '-' + month
				this.showPickerEnterJob = !this.showPickerEnterJob
			},
			// 当前求职状态
			onConfirmCurrent(value) {
				this.current = this.columnsCurrent[value].id
				this.currentName = this.columnsCurrent[value].text
				this.showPickerCurrent = !this.showPickerCurrent
			},
			handleSubmit() {
				if (!this.current) {
					this.$refs.uTips.show({
						title: '请选择求职状态',
						type: 'error'
					})
					return false
				}

				http.post(api.reg_resume_int_step3, {
						enter_job_time: this.enter_job_time,
						current: this.current
					})
					.then(res => {
						if (!this.enter_job_time) {
							uni.navigateTo({
								url: '/member/personal/resume_add_int/step4_nowork'
							})
						} else {
							uni.navigateTo({
								url: '/personal/AddResumeByInteractive/RegIntStep4'
							})
						}
					})
					.catch(err => {
						console.log(err)
					})
			}
		}
	}
</script>

<style lang="scss" scoped></style>
